import { createStore } from "vuex";
import axios from "axios";
const store = createStore({
    state(){
        return{
            num:10,
            list:[]
        };
    },
    getters:{

    },
    mutations:{
       updateList(state,payload){
        state.list = payload.data;
       }
    },
    actions:{
       getData({commit},payload){
        console.log('进入了actions',payload);
        axios.get('http://localhost:3009/goods')
        .then((res)=>{
            // console.log(res);
            commit('updateList',{
                data:res
            })
        })
       }
    },
    modules:{

    }
});
export default store;